<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script src="/benchmark/js/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript" src="/benchmark/js/js.cookie.js"></script>
<title>BenchmarkTest00015</title>
</head>
<body>
    <form action="/benchmark/cmdi-00/BenchmarkTest00015" method="POST" id="FormBenchmarkTest00015">
        <div>
            <label>Please explain your answer:</label>
        </div>
        <br />
        <div>
            <textarea rows="4" cols="50" id="BenchmarkTest00015Area" name="BenchmarkTest00015Area"></textarea>
        </div>
        <div>
            <label>Any additional note for the reviewer:</label>
        </div>
        <div>
            <input type="text" id="answer" name="answer"></input>
        </div>
        <br />
        <div>
            <label>An AJAX request will be sent with a header named BenchmarkTest00015 and value:</label> <input type="text" id="BenchmarkTest00015" name="BenchmarkTest00015" value="ECHOOO" class="safe"></input>
        </div>

        <div>
            <input type="button" id="login-btn" value="Login" onclick="submitForm()" />
        </div>
    </form>
    <div id="ajax-form-msg1">
        <pre>
            <code class="prettyprint" id="code"></code>
        </pre>
    </div>
    <script type="text/javascript">
        $('.safe').keypress(function (e) {
            if (e.which == 13) {
                submitForm();
                return false;
            }
        });

        function submitForm() {
            var formData = $("#FormBenchmarkTest00015").serialize();
            var URL = $("#FormBenchmarkTest00015").attr("action");
            var text = $("#FormBenchmarkTest00015 input[id=BenchmarkTest00015]")
                    .val();

            var xhr = new XMLHttpRequest();
            xhr.open("POST", URL, true);

            xhr.setRequestHeader('BenchmarkTest00015', text);

            xhr.onreadystatechange = function () {
                if (xhr.readyState == XMLHttpRequest.DONE && xhr.status == 200) {
                    $("#code").html(xhr.responseText);
                } else {
                    $("#code").html("Error " + xhr.status + " occurred.");
                }
            }
            xhr.send(formData);
        }

        function escapeRegExp(str) {
            return str.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1");
        }

        function replaceAll(str, find, replace) {
            return str.replace(new RegExp(escapeRegExp(find), 'g'), replace);
        }

        String.prototype.decodeEscapeSequence = function () {
            var txt = replaceAll(this, ";", "");
            txt = replaceAll(txt, "&#", "\\");
            return txt.replace(/\\x([0-9A-Fa-f]{2})/g, function () {
                return String.fromCharCode(parseInt(arguments[1], 16));
            });
        };
    </script>
</body>
</html>
